From: Timothy Bess Date: Wed, 28 Feb 2018 02:34:04 +0000 (-0500) Subject: Issue #5087 X-Git-Tag: archive/raspbian/0.35.0-2+rpi1~3^2^2^2^2^2^2^2~22^2~2^2~67^2~5 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/success//%22http:/www.example.com/cgi/success/?a=commitdiff_plain;h=68a681ff0395452784f8b47bddbd23c559003d6f;p=cargo.git Issue #5087 * remove Workspace::current_manifest * remove incorrect logging * move empty check to Packages::into_package_id_specs * add test case mentioned in issue --- diff --git a/src/cargo/core/workspace.rs b/src/cargo/core/workspace.rs index 7a5ef6f3e..0ed855d06 100644 --- a/src/cargo/core/workspace.rs +++ b/src/cargo/core/workspace.rs @@ -144,10 +144,6 @@ impl<'cfg> Workspace<'cfg> { Ok(ws) } - pub fn current_manifest(&self) -> &Path { - &self.current_manifest - } - /// Creates a "temporary workspace" from one package which only contains /// that package. /// diff --git a/src/cargo/ops/cargo_compile.rs b/src/cargo/ops/cargo_compile.rs index 7891ad304..4ff4e240d 100644 --- a/src/cargo/ops/cargo_compile.rs +++ b/src/cargo/ops/cargo_compile.rs @@ -155,7 +155,12 @@ impl<'a> Packages<'a> { .collect() } }; - Ok(specs) + if specs.is_empty() { + bail!("Workspace contains no members to be compiled. \ + Be sure all workspace members haven't been excluded") + } else { + Ok(specs) + } } } @@ -234,12 +239,6 @@ pub fn compile_ws<'a>(ws: &Workspace<'a>, &specs)?; let (packages, resolve_with_overrides) = resolve; - if specs.is_empty() { - bail!("manifest path `{}` contains no package: The manifest is virtual, \ - and the workspace has no members.", - ws.current_manifest().display()) - } - let to_builds = specs.iter().map(|p| { let pkgid = p.query(resolve_with_overrides.iter())?; let p = packages.get(pkgid)?; diff --git a/src/cargo/ops/cargo_doc.rs b/src/cargo/ops/cargo_doc.rs index 9f21d1bd6..d747b42d0 100644 --- a/src/cargo/ops/cargo_doc.rs +++ b/src/cargo/ops/cargo_doc.rs @@ -22,12 +22,6 @@ pub fn doc(ws: &Workspace, options: &DocOptions) -> CargoResult<()> { &specs)?; let (packages, resolve_with_overrides) = resolve; - if specs.is_empty() { - bail!("manifest path `{}` contains no package: The manifest is virtual, \ - and the workspace has no members.", - ws.current_manifest().display()) - }; - let pkgs = specs.iter().map(|p| { let pkgid = p.query(resolve_with_overrides.iter())?; packages.get(pkgid) diff --git a/tests/testsuite/build.rs b/tests/testsuite/build.rs index 2c15367e5..9dfafc133 100644 --- a/tests/testsuite/build.rs +++ b/tests/testsuite/build.rs @@ -137,6 +137,24 @@ fn incremental_config() { .with_status(0)); } +#[test] +fn cargo_compile_with_workspace_excluded() { + let p = project("foo") + .file("Cargo.toml", r#" + [package] + name = "foo" + version = "0.1.0" + authors = [] + "#) + .file("src/main.rs", "fn main() {}") + .build(); + + assert_that( + p.cargo("build").arg("--all").arg("--exclude").arg("foo"), + execs().with_stderr_does_not_contain("[..]virtual[..]") + .with_status(101)); +} + #[test] fn cargo_compile_manifest_path() { let p = project("foo")